<!doctype html>
<html>
	<head>
		<meta charset="utf-8" />
		<style>
			@charset"utf-8";
			html,body,div,span,a,img,em,i,h1,h2,h3,h4,h5,h6,ul,ol,li,form,input,textarea,select,button,header,nav,section,article,aside,address,abbr,blockquote,iframe,thead,tbody,tfoot,fieldset,figure,code,caption,del,dfn,dl,dt,dd,p,q,pre,object,legend,hgroup{margin:0;padding:0;border:0;outline:0;box-sizing:border-box;}
			:after,:before{box-sizing:border-box}
			html,body{position:absolute;top:0;left:0;right:0;bottom:0;font-family:'Microsoft YaHei', '\5FAE\8F6F\96C5\9ED1', sans-serif;font-size:14px;overflow:hidden;}
			img,span,p,h1,h2,h3,h4,h5,h6{overflow:hidden}
			table{border-spacing:0;border-collapse:collapse}
			textarea{overflow:auto;resize:none;vertical-align:top}
			button,select{overflow:visible;cursor:pointer}
			a{text-decoration:none;color:inherit;}
			:active,:focus,:hover,:link,:visited{outline:0;text-decoration:none;}
			li,ol,ul{list-style:none}
			body{padding:200px;}
			button,img,span,a{display: inline-block;}
			input{display:inline-block;width:200px;height:40px;line-height:40px;border:1px solid #ddd;padding:0 10px;float:left;}
			#button{display:inline-block;width:70px;height:40px;border:1px solid #ddd;cursor:pointer;text-align:center;line-height:40px;float:left;margin-left:10px;}
			#replay{display:inline-block;width:70px;height:40px;border:1px solid #ddd;cursor:pointer;text-align:center;line-height:40px;float:left;margin-left:10px;}
		</style>
	</head>
	<body>
		<input type="text" id="num">
		<div id="button">点击猜数</div>
		<div id="replay">重新开始</div>
		<script>
			var i;
			var num = document.getElementById('num');
			var button = document.getElementById('button');
			var replay = document.getElementById('replay');
			function ranum(){
				i = ~~(Math.random() * 900 + 100);
			}
			ranum();
			button.onclick = function(e){
				if(num.value == '' && isNaN(num.value)){
					num.value = '请输入数字...';
				}else{
					var res = parseInt(num.value) - i;
					if(res == 0){
						num.value = '恭喜你猜对啦...';
					}else{
						res < 0 && (num.value = '小了哦...');
						res > 0 && (num.value = '大了哦...');
					}
				}
			};
			replay.onclick = function(e){
				ranum();
			};
			num.onclick = function(){
				num.value = '';
			}
		</script>
	</body>
</html>